package 综合练习题3;

import java.util.*;

//订单处理系统的主应用类，用于测试订单处理功能
public class OrderProcessingApp {
 public static void main(String[] args) {
     // 创建订单列表
     List<Order<User>> orders = new ArrayList<>();
     List<String> products1 = Arrays.asList("Product1", "Product2");
     List<String> products2 = Arrays.asList("Product3", "Product4");
     User user1 = new User("Alice", "New York");
     User user2 = new User("Bob", "Los Angeles");
     Order<User> order1 = new Order<>("1", user1, products1);
     Order<User> order2 = new Order<>("2", user2, products2);
     orders.add(order1);
     orders.add(order2);

     // 过滤出指定城市用户的订单
     List<Order<User>> filteredOrders = OrderProcessingSystem.filterOrdersByCity(orders, "New York");
     System.out.println("纽约的订单：");
     filteredOrders.forEach(order -> System.out.println(order.getOrderId()));

     // 合并多个订单列表
     List<List<Order<User>>> orderLists = new ArrayList<>();
     orderLists.add(orders);
     List<Order<User>> mergedOrders = OrderProcessingSystem.mergeOrders(orderLists);
     System.out.println("合并后的订单数量：" + mergedOrders.size());

     // 统计各城市的订单数量
     Map<String, Integer> cityOrderCount = OrderProcessingSystem.countOrdersByCity(orders);
     System.out.println("各城市的订单数量：");
     cityOrderCount.forEach((city, count) -> System.out.println(city + ": " + count));
 }
}